import {get,post} from "../untils/db"


Page({
  data: {
  files:"",
  users:""
  },
  async onLoad(){
    this.setData({
      users:wx.getStorageSync('users')
    })
    console.log(this.data.users);
    
    },
  close: function () {
      this.setData({
          showActionsheet: false
      })
  },
  btnClick(e) {
      console.log(e)
      this.close()
  },
  gai(){
    wx.navigateTo({
      url: '../password/password',
    })
  },
  myselect(e){
  console.log(e.detail.tempFilePaths[0]);

  
  this.setData({
    files:e.detail.tempFilePaths[0]
  },async ()=>{
    let ext=this.data.files.split(".").reverse()[0]
    console.log(ext);
   let will= wx.cloud.uploadFile({
     cloudPath:new Date().getTime()+'.'+ext,
     filePath:this.data.files
   })

   let result=await will
  //  new Promise(will).then(res=>{
  //    log
  //  })

   console.log(result);
  //   let token=wx.getStorageSync('login')
  // let res=await post("/api/updateAvatar",{avatar:this.data.files},token)
  // console.log(res);
  })
  }
})
